package com.hualan.sfzy.service.counselor.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.constant.CommonConstant;
import com.hualan.sfzy.entity.counselor.CounselorPriceStandard;
import com.hualan.sfzy.mapper.counselor.CounselorPriceStandardMapper;
import com.hualan.sfzy.service.counselor.CounselorPriceStandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("CounselorPriceStandardService")
public class CounselorPriceStandardServiceImpl implements CounselorPriceStandardService {

    @Autowired
    private CounselorPriceStandardMapper counselorPriceStandardMapper;

    @Override
    public int add(CounselorPriceStandard counselorPriceStandard) {
        return counselorPriceStandardMapper.insert(counselorPriceStandard);
    }

    @Override
    public int remove(Integer id) {
        return counselorPriceStandardMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return counselorPriceStandardMapper.deleteBatch(ids);
    }

    @Override
    public int edit(CounselorPriceStandard counselorPriceStandard) {
        return counselorPriceStandardMapper.update(counselorPriceStandard);
    }

    @Override
    public List<CounselorPriceStandard> find() {
        return counselorPriceStandardMapper.select(null);
    }

    @Override
    public Map<String, Object> findByPage(Integer pageNum, Integer pageSize, CounselorPriceStandard entity) {
        PageHelper.startPage(pageNum,pageSize);

        List<CounselorPriceStandard> list = counselorPriceStandardMapper.select(entity);

        PageInfo<CounselorPriceStandard> pageInfo = new PageInfo<>(list);

        Map<String, Object> map = new HashMap<>();

        map.put(CommonConstant.PAGE_LIST,list);
        map.put(CommonConstant.PAGE_TOTAL,pageInfo.getPages());
        map.put(CommonConstant.TOTAL,pageInfo.getTotal());

        return map;
    }

    @Override
    public CounselorPriceStandard findById(Integer id) {
        return counselorPriceStandardMapper.selectById(id);
    }


}
